            var pushNotification;
            
            function push_init() {

                console.log("LOG PUSH: push init");

                pushNotification = window.plugins.pushNotification;
            
            try {    
                if ( device.platform == 'android' || device.platform == 'Android' || device.platform == "amazon-fireos" ){
                    console.log("LOG PUSH: Registrar Android");

                    //TODO. evitar k se registre cada vez, pero esto puede tener un bug.
                    //Solucion 1: La que tengo en AlertasApp que esta hecha para Android
                    //Solucion 2: guardar en preferencias si ya los hemos registrado

                    pushNotification.register(
                    successHandler,
                    errorHandler,
                    {
                        "senderID":"358686006771",
                        "ecb":"onNotification"
                    });
                } else if ( device.platform == 'blackberry10'){
                    pushNotification.register(
                    successHandler,
                    errorHandler,
                    {
                        invokeTargetId : "replace_with_invoke_target_id",
                        appId: "replace_with_app_id",
                        ppgUrl:"replace_with_ppg_url", //remove for BES pushes
                        ecb: "pushNotificationHandler",
                        simChangeCallback: replace_with_simChange_callback,
                        pushTransportReadyCallback: replace_with_pushTransportReady_callback,
                        launchApplicationOnPush: true
                    });
                } else {
                    console.log("LOG PUSH: Registrar IOS"); 
                    pushNotification.register(
                    tokenHandler,
                    errorHandler,
                    {
                        "badge":"true",
                        "sound":"true",
                        "alert":"true",
                        "ecb":"onNotificationAPN"
                    });
                }
            }
            catch(err)
            {
                console.log("LOG PUSH: REGISTRAR ERROR " + err); 
            }
				/*document.addEventListener("backbutton", function(e)
				{
                	$("#app-status-ul").append('<li>backbutton event received</li>');
  					
      				if( $("#home").length > 0)
					{
						// call this to get a new token each time. don't call it to reuse existing token.
						//pushNotification.unregister(successHandler, errorHandler);
						e.preventDefault();
						navigator.app.exitApp();
					}
					else
					{
						navigator.app.backHistory();
					}
				}, false);*/
			
            }
            
            // handle APNS notifications for iOS
            function onNotificationAPN(e) {
                if (e.alert) {
                     $("#app-status-ul").append('<li>push-notification: ' + e.alert + '</li>');
                     navigator.notification.alert(e.alert);
                }
                    
                if (e.sound) {
                    var snd = new Media(e.sound);
                    snd.play();
                }
                
                if (e.badge) {
                    pushNotification.setApplicationIconBadgeNumber(successHandler, e.badge);
                }
            }
            
            // handle GCM notifications for Android
            function onNotification(e) {
                console.log("LOG PUSH: onNotification RECEIVED:" + e.event);
                
                switch( e.event )
                {
                    case 'registered':
					if ( e.regid.length > 0 )
					{
						// Your GCM push server needs to know the regID before it can push to this device
						// here is where you might want to send it the regID for later use.
						console.log("LOG PUSH: REGISTERED regID = " + e.regid);
                        
                        if(window.localStorage.getItem("regId") == null){
                            console.log("LOG PUSH: HACER POST A MI WEB SERVER");
                                var adapter_push = new JSONPPushAdapter();
                                adapter_push.registrarEnServidor(e.regid);
                        }
                        else
                        {
                            console.log("LOG PUSH: DISPOSITIVO YA REGISTRADO EN GCM y Mi SERVER");
                        }
					}
                    break;
                    
                    case 'message':
                    	// if this flag is set, this notification happened while we were in the foreground.
                    	// you might want to play a sound to get the user's attention, throw up a dialog, etc.
                    	if (e.foreground)
                    	{
                            console.log("LOG_DEBUG - Push_utils message:e.foreground");
						      
						        // on Android soundname is outside the payload. 
					                // On Amazon FireOS all custom attributes are contained within payload
					                var soundfile = e.soundname || e.payload.sound;
					                // if the notification contains a soundname, play it.
					                var my_media = new Media("/android_asset/www/"+ soundfile);

							my_media.play();
						}
						else
						{	// otherwise we were launched because the user touched a notification in the notification tray.
							if (e.coldstart){
                                console.log("LOG_DEBUG - Push_utils message:e.coldstart");
							} else {
                                console.log("LOG_DEBUG - Push_utils message:background");
                            }
						}
							
                        console.log('MESSAGE -> MSG: ' + e.payload.message);
						
                        //android only
						console.log('MESSAGE -> MSGCNT: ' + e.payload.msgcnt);
                        //$("#app-status-ul").append('<li>MESSAGE -> MSGCNT: ' + e.payload.msgcnt + '</li>');

                        //amazon-fireos only
                        console.log('MESSAGE -> TIMESTAMP: ' + e.payload.timeStamp);
                        //$("#app-status-ul").append('<li>MESSAGE -> TIMESTAMP: ' + e.payload.timeStamp + '</li>');

                    break;
                    
                    case 'error':
						console.log('ERROR -> MSG:' + e.msg + '</li>');
                    break;
                    
                    default:
						console.log('EVENT -> Unknown, an event was received and we do not know what it is</li>');
                    break;
                }
            }
            
            function tokenHandler (result) {
                //$("#app-status-ul").append('<li>token: '+ result +'</li>');
                console.log("LOG PUSH: tokenHandler -> " + result);
                // Your iOS push server needs to know the token before it can push to this device
                // here is where you might want to send it the token for later use.
            }
			
            function successHandler (result) {
                //$("#app-status-ul").append('<li>success:'+ result +'</li>');
                console.log("LOG PUSH: successHandler -> " + result);
            }
            
            function errorHandler (error) {
                //$("#app-status-ul").append('<li>error:'+ error +'</li>');
                console.log("LOG PUSH: errorHandler -> " + error);
            }